<template>
  <v-card
    title="港口计划货量"
    bgImg="https://oss.sdland-sea.com/group2/M01/16/06/Cof8E2IxgOCAYlXeAACSfyrQms0977.png"
  >
    <div class="card-container">
      <div class="list-header">
        <div class="tidanhao">{{ tag == 1 ? "提单号" : "车次" }}</div>
        <div class="chuanming">船名</div>
        <div class="huoming">货名</div>
        <div class="huowei">{{ tag == 1 ? "货位" : "起运港" }}</div>
        <div class="daiyunren">{{ tag == 1 ? "代运人" : "到站" }}</div>
        <div class="shouhuoren">收货人</div>
        <div class="jihuaDunshu">计划吨数</div>
        <div class="shichang">平均时长</div>
      </div>
      <div class="list-body">
        <div :id="id" class="swiper mySwiperCont" @click="handleParentClick">
          <div
            class="swiper-wrapper"
            :class="{ flexSwiperWrapper: listData.length < maxLength }"
          >
            <div
              class="swiper-slide"
              v-for="(item, index) in listData"
              :key="index"
              :data-index="index"
            >
              <div class="list-item" :data-index="index">
                <div class="tidanhao">
                  {{ tag == 1 ? item.tdh : item.sequence }}
                </div>
                <div class="chuanming">{{ item.shipName }}</div>
                <div class="huoming" :title="item.cargoName">
                  {{ item.cargoName }}
                </div>
                <div
                  class="huowei"
                  :title="tag == 1 ? item.cargoLocCode : item.startPortName"
                >
                  {{ tag == 1 ? item.cargoLocCode : item.startPortName }}
                </div>
                <div
                  class="daiyunren"
                  :title="tag == 1 ? item.setOwner : item.stationName"
                >
                  {{ tag == 1 ? item.setOwner : item.stationName }}
                </div>

                <div class="shouhuoren" :title="item.getOwner">
                  {{ item.getOwner }}
                </div>

                <div class="jihuaDunshu">{{ item.weightPlan }}</div>
                <div class="shichang">{{ item.roadTime || 0 }} h</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </v-card>
</template>

<script>
import MIXIN from "./mxin";
import { getPortPlanInfo, getListDetail } from "@/api/networShow/dataV";
export default {
  mixins: [MIXIN],
  data() {
    return {
      id: "PortPlanInfo",
      maxLength: 7
    };
  },
  methods: {
    async getListData() {
      this.listData = [];
      const { data } = await getPortPlanInfo(this.tag);
      if (data.code == 200) {
        this.listData = data.data;
      }
    },

    handleMap(index) {
      if (this.tag != 1) {
        return;
      }
      this.$store.commit("dataV/UPDATE_HANLDER", "truck_portPlan"); // 更新与操作
      this.centerMap.addDefaultPort();
      this.centerMap.resetMap();
      this.centerMap.clearTruck();
      // 移除 精品线路
      this.centerMap.clearLine();
      // 移除 精品线路点
      this.centerMap.clearStartEndPoint();
      const id = this.listData[index].id;
      getListDetail(id).then(res => {
        const { data } = res;
        if (data.code == 200) {
          if (JSON.stringify(data.data) == "{}") {
            return;
          }
          this.centerMap.addTruck(data.data);
        }
      });
    }
  }
};
</script>

<style lang="less" scoped>
.card-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .list-header,
  .list-item {
    width: 100%;
    display: flex;
    height: 22px;
    line-height: 22px;
    background: rgba(216, 216, 216, 0.25);
    font-size: 12px;
    font-family: SourceHanSansCN-Bold, SourceHanSansCN;
    font-weight: bold;
    color: #ffffff;
    display: flex;
    & > div {
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
      padding: 0 3px;
      box-sizing: border-box;
    }
    .tidanhao {
      width: 95px;
    }
    .daiyunren {
      width: 80px;
    }
    .shouhuoren {
      width: 90px;
    }
    .chuanming {
      width: 70px;
    }
    .huowei {
      width: 60px;
    }
    .huoming {
      width: 58px;
    }
    .jihuaDunshu {
      width: 65px;
    }
    .shichang {
      flex: 1;
    }
  }
  .list-body {
    flex: 1;
    .flexSwiperWrapper {
      display: flex;
      flex-direction: column;
      .swiper-slide {
        height: 34px;
        line-height: 34px;
      }
    }
    .mySwiperCont {
      height: 220px;
      .swiper-slide {
        &:nth-child(odd) {
          .list-item {
            background: transparent;
          }
        }
        &:nth-child(even) {
          .list-item {
            background: rgba(56, 64, 138, 0.25);
          }
        }
      }
      .list-item {
        height: 34px;
        line-height: 34px;
        cursor: pointer;
      }
    }
  }
}
</style>
